package io.gitee.cloudladder.obsidian.swagger2.example.controller;

import io.gitee.cloudladder.obsidian.swagger2.annotation.ApiOperationSort;
import io.gitee.cloudladder.obsidian.swagger2.example.entity.BaseDataTypeParamObject;
import io.gitee.cloudladder.obsidian.swagger2.example.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Api(value = "Test Form Parameter Controller")
@RestController
public class TestFormParameterController {

    @ApiOperationSort(0)
    @PostMapping("/test/form/string")
    @ApiOperation(value = "testFormString", consumes = "multipart/form-data")
    public void testFormString(@RequestPart String param) {
        log.info("testFormString: param = {}", param);
    }

    @ApiOperationSort(1)
    @PostMapping("/test/form/file")
    public void testFormFile(@RequestPart MultipartFile param) {
        log.info("testFormFile: param = {}", param);
    }

    @ApiOperationSort(2)
    @PostMapping("/test/form/object/base")
    public void testFormObjectBase(@ModelAttribute BaseDataTypeParamObject params) {
        log.info("testFormObjectBase: param = {}", params);
    }

    @ApiOperationSort(3)
    @PostMapping("/test/form/fileAndObject")
    public void testFormFileAndObject(@RequestPart MultipartFile file, @RequestPart User user) {
        log.info("testFormListInteger: file = {}, user = {}", file, user);
    }

}

